package com.gin.kotlin.no_gay_alliance.fragment.main

import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import androidx.core.view.MenuProvider
import com.gin.kotlin.no_gay_alliance.R
import com.gin.kotlin.no_gay_alliance.activity.UserCenterActivity
import com.gin.kotlin.no_gay_alliance.app.App
import com.gin.kotlin.no_gay_alliance.argument.ItemArgument
import com.gin.kotlin.no_gay_alliance.argument.ItemArgument.Mode
import com.gin.kotlin.no_gay_alliance.base.FragmentStateContainer
import com.gin.kotlin.no_gay_alliance.fragment.main.me.BlockConfigFragment
import com.gin.kotlin.no_gay_alliance.fragment.main.me.CheckInStatusFragment
import com.gin.kotlin.no_gay_alliance.fragment.main.me.MissionFragment
import com.gin.kotlin.no_gay_alliance.fragment.main.me.follow.FollowDynamicsFragment
import com.gin.kotlin.no_gay_alliance.fragment.main.me.follow.FollowUserFragment
import com.gin.kotlin.no_gay_alliance.fragment.main.me.item.ItemInventoryFragment
import com.gin.kotlin.no_gay_alliance.fragment.main.me.item.ItemStoreFragment

/**
 * * 首页 - 我的
 * *  包含功能：关注动态，关注列表，任务(自动签到)，屏蔽管理，道具管理，跳转用户中心
 */
class MainMeFragment : AbstractMainTabFragment(), MenuProvider {
    override fun obtainFragmentStateContainers() = listOf(
        FragmentStateContainer("签到") { CheckInStatusFragment() },
        FragmentStateContainer("任务") { MissionFragment() },
        FragmentStateContainer("关注动态") { FollowDynamicsFragment() },
        FragmentStateContainer("关注列表") { FollowUserFragment() },
        FragmentStateContainer("屏蔽管理") { BlockConfigFragment() },
        FragmentStateContainer(getString(R.string.fragment_tab_title_item_store)) { ItemStoreFragment.newInstance(ItemArgument(Mode.Linear)) },
        FragmentStateContainer(getString(R.string.fragment_tab_title_item_inventory)) { ItemInventoryFragment.newInstance(ItemArgument(Mode.Linear)) },
    )

    override fun onCreateView2() {
    }

    override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
        menuInflater.inflate(R.menu.user_center, menu)
    }

    override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
        if (menuItem.itemId == R.id.mi_user_center) {
            UserCenterActivity.startActivity(requireContext(), App.INSTANCE.account.userId)
            return true
        }

        return false
    }
}